package com.danbay.cloud.account.service.api;

import com.danbay.cloud.account.dto.AddEnterpriseDto;
import com.danbay.cloud.account.dto.EnterpriseAccountDto;
import com.danbay.cloud.account.dto.EnterpriseAccountInfoDto;
import com.danbay.cloud.account.dto.EnterpriseInfoDto;
import com.danbay.framework.db.pagination.PageParam;
import com.danbay.framework.db.pagination.PageResult;
import com.danbay.framework.exception.BusinessException;
import com.danbay.framework.springnc.annotation.AutoController;
import com.danbay.framework.springnc.annotation.RequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 企业信息管理
 *
 * @author SJG
 *         2017/12/26.
 */
@AutoController
@RequestMapping("/account-service/enterprise")
@Api("企业信息操作接口")
public interface IEnterpriseService {

    /**
     * 分页查找企业信息
     *
     * @param param 分页查询查询参数
     * @return 返回分页的企业信息列表
     */
    @ApiOperation(value = "分页查找企业信息，返回分页的企业信息列表")
    @RequestMapping(value = "/findByPage", method = RequestMethod.POST, consumes = "application/json; charset=utf-8")
    PageResult<EnterpriseInfoDto> findByPage(@RequestBody PageParam<EnterpriseInfoDto> param);

    /**
     * 取企业信息
     *
     * @param eid 企业id
     * @return 企业信息
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "取企业信息")
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    EnterpriseInfoDto get(@ApiParam("企业id") Integer eid) throws BusinessException;

    /**
     * 添加企业信息
     *
     * @param info 企业信息
     * @return 企业id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "添加企业信息")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    Integer add(@RequestBody AddEnterpriseDto info) throws BusinessException;

    /**
     * 添加企业账户
     * 添加完后前端再调用发送默认密码
     *
     * @param accountDto 企业账户信息
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "添加企业账户", notes = "添加完后前端再调用发送默认密码")
    @RequestMapping(value = "/addEnterpriseAccount", method = RequestMethod.POST)
    void addEnterpriseAccount(@RequestBody EnterpriseAccountDto accountDto) throws BusinessException;

    /**
     * 取企业账户信息
     *
     * @param eid 企业id
     * @return 企业账户信息
     */
    @ApiOperation(value = "取企业账户信息")
    @RequestMapping(value = "/getAccountInfo", method = RequestMethod.GET)
    EnterpriseAccountInfoDto getAccountInfo(Integer eid);

    /**
     * 修改企业名
     *
     * @param eid  企业id
     * @param name 企业名
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "修改企业名")
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    void edit(@ApiParam("企业id") Integer eid, @ApiParam("企业名") String name) throws BusinessException;

    /**
     * 删除企业信息
     * 只有试用账户才能被删除，确认相关提示并删除后，与该账号关联的设备
     * 信息和房源信息同样被取消关联和删除。
     *
     * @param eid 企业id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "删除企业信息", notes = "只有试用账户才能被删除，确认相关提示并删除后，与该账号关联的设备\n" +
            "信息和房源信息同样被取消关联和删除。 ")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    void delete(@ApiParam("企业id") Integer eid) throws BusinessException;

    /**
     * 绑定账户组和账户
     *
     * @param eid       企业id
     * @param groupId   账户组id
     * @param accountId 账户id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "给企业绑定账户组和账户")
    @RequestMapping(value = "/bindAccount", method = RequestMethod.POST)
    void bindAccount(Integer eid, Integer groupId, String accountId) throws BusinessException;

    /**
     * 更改企业关联的账户
     * 相当于创建新的账户绑定到该企业
     *
     * @param eid      企业信息id
     * @param userName 用户名
     * @param phoneNum 手机号
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "更改企业关联的账户", notes = "相当于创建新的账户绑定到该企业")
    @RequestMapping(value = "/changeAccount", method = RequestMethod.POST)
    void changeAccount(@ApiParam("企业信息id") Integer eid, @ApiParam("用户名") String userName, @ApiParam("手机号") String phoneNum) throws BusinessException;

    /**
     * 升级试用企业到正式企业
     * 1.把企业信息标识为正式
     * 2.删除试用合同号
     * 3.补充合同号（前端调用新增合同号）
     *
     * @param eid 企业id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "升级试用企业到正式企业", notes = "1.把企业信息标识为正式,2.删除试用合同号,3.补充合同号（前端调用新增合同号）")
    @RequestMapping(value = "/upgrade", method = RequestMethod.POST)
    void upgrade(@ApiParam("企业id") Integer eid) throws BusinessException;

    /**
     * 冻结企业
     * 1.冻结企业,2.将企业绑定账户置为不可用
     *
     * @param eid 企业id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "冻结企业", notes = "1.冻结企业,2.将企业绑定账户置为不可用")
    @RequestMapping(value = "/freeze", method = RequestMethod.POST)
    void freeze(@ApiParam("企业id") Integer eid) throws BusinessException;

    /**
     * 解冻企业
     * 1.解冻企业,2.将企业绑定账户置为可用
     *
     * @param eid 企业id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "解冻企业", notes = "1.解冻企业,2.将企业绑定账户置为可用")
    @RequestMapping(value = "/unfreeze", method = RequestMethod.POST)
    void unfreeze(@ApiParam("企业id") Integer eid) throws BusinessException;

    /**
     * 企业账户注册成功后,发送注册短信
     *
     * @param mobile 企业账户电话
     * @param name   企业名
     */
    @ApiOperation(value = "发送注册短信")
    @RequestMapping(value = "/sendRegMessage", method = RequestMethod.POST)
    void sendRegMessage(@ApiParam("企业账户电话") @RequestParam("mobile") String mobile, @ApiParam("企业名") @RequestParam("name") String name) throws BusinessException;

    /**
     * 修改绑定企业账户名和电话，发送账户绑定短信
     *
     * @param mobile 企业账户电话
     * @param name   企业名
     */
    @ApiOperation(value = "发送账户绑定短信")
    @RequestMapping(value = "/sendBindMessage", method = RequestMethod.POST)
    void sendBindMessage(@ApiParam("企业账户电话") @RequestParam("mobile") String mobile, @ApiParam("企业名") @RequestParam("name") String name) throws BusinessException;

    /**
     * 企业账户变更时，发送账户变更短信
     *
     * @param mobile 企业账户电话
     * @param name   企业名
     */
    @ApiOperation(value = "发送账户变更短信")
    @RequestMapping(value = "/sendAccountChangeMessage", method = RequestMethod.POST)
    void sendAccountChangeMessage(@ApiParam("企业账户电话") @RequestParam("mobile") String mobile, @ApiParam("企业名") @RequestParam("name") String name) throws BusinessException;
}
